package com.xdcplus.web.common.enums.device;

import lombok.Getter;

/**
 * @author Richard.Li
 */

@Getter
public enum BdOpeAndRegion {

    ZR(1020),
    PK(1030),
    YH(1050),
    BSG(2010),
    LPCVD(2020),
    LK(2030),
    PSG(2040),
    ALD(3010),
    PECVDZM(3020),
    PECVDBM(3030),
    SWYS(4010),
    CSFX(5020),
    PE(5030);

    private final int code;

    BdOpeAndRegion(int code) {
        this.code = code;
    }

    public static BdOpeAndRegion fromCode(int code) {
        for (BdOpeAndRegion processCode : BdOpeAndRegion.values()) {
            if (processCode.getCode() == code) {
                return processCode;
            }
        }
        throw new IllegalArgumentException("Invalid code: " + code);
    }

    // 新增的通过字符串获取 code 的方法
    public static int getCodeByName(String name) {
        try {
            BdOpeAndRegion region = BdOpeAndRegion.valueOf(name);
            return region.getCode();
        } catch (IllegalArgumentException e) {
            throw new IllegalArgumentException("Invalid region name: " + name);
        }
    }


}